package guicommon.controls;

import guicommon.gui.ControlMessage;
import guicommon.gui.TextBoxMessage;
import java.awt.Component;
import javax.swing.JTextField;

public class TextBox extends Control {

    private JTextField textBox;

    public void SetText(String text) {
        Update("SetText", text);
        textBox.setText(text);
    }

    public TextBox() {
        textBox = new JTextField();
    }

    public String GetText() {
        return textBox.getText();
    }

    @Override
    public ControlMessage ToMessage() {
        TextBoxMessage result = new TextBoxMessage();
        SetCommonFields(result);
        result.SetText(GetText());
        return result;
    }

    protected Component GetComponent() {
        return textBox;
    }
}
